#include "canigbus.h"
#include "ui_canigbus.h"

//outside initialization instance ptr
CanIGBus* CanIGBus::instance = nullptr;
CanIGBus::CanIGBus(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::CanIGBus)
{
    ui->setupUi(this);
}

CanIGBus::~CanIGBus()
{
    delete ui;
}
//make it mutex
CanIGBus* CanIGBus::getInstance()
{
    //multi thread to access it ,may cause compete.
    static QMutex mutex;
    if(!instance)
    {
        //make it to lock to solve thread saftey
        QMutexLocker locker(&mutex);
        if(!instance)
        {
            qDebug()<<"new CanIGBus";
            instance = new CanIGBus;
        }
    }
    return instance;
}
